package org.ttitfly.ttcore.entity.menu;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.ttitfly.ttcore.entity.IdEntity;
import org.ttitfly.ttcore.entity.account.Role;
@Entity
//表名与类名不相同时重新定义表名.
@Table(name = "s_menu")
//默认的缓存策略.
//@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class SystemMenu extends IdEntity{
	//名称
	@Column(name = "title")
	private String title;
	
	//英文名称
	@Column(name = "keyword")
	private String keyword;
	
	//父类ID,0代表顶级
	@Column(name = "parent_id")
	private Long parentId = new Long(0);
	
	//是否是叶子节点
	@Column(name = "leaf")
	private Integer leaf;
	
	//排序
	@Column(name = "order_num")
	private Integer orderNum;
	
	@Column(name = "url")
	private String url;
	
	@Column(name = "style")
	private String style;
	
	private List<Role> roles = new ArrayList<Role>();
	
	@ManyToMany(mappedBy="menus")
	public List<Role> getRoles() {
		return roles;
	}


	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}


	public String getStyle() {
		return style;
	}


	public void setStyle(String style) {
		this.style = style;
	}


	public String getKeyword() {
		return keyword;
	}
	

	public void setKeyword(String keyword) {
		this.keyword = keyword;
	}


	public Long getParentId() {
		return parentId;
	}


	public void setParentId(Long parentId) {
		this.parentId = parentId;
	}


	

	public String getTitle() {
		return title;
	}


	public void setTitle(String title) {
		this.title = title;
	}



	public Integer getLeaf() {
		return leaf;
	}


	public void setLeaf(Integer leaf) {
		this.leaf = leaf;
	}


	public Integer getOrderNum() {
		return orderNum;
	}


	public void setOrderNum(Integer orderNum) {
		this.orderNum = orderNum;
	}

	
	public String getUrl() {
		return url;
	}


	public void setUrl(String url) {
		this.url = url;
	}


	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
}
